package com.th.supcom.pds.impl.service.internal.phamapply;

import java.util.List;

import net.carefx.framework.exception.BusinessException;

import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.th.supcom.pds.domain.vo.InpPhamApplyDetailVO;
import com.th.supcom.pds.domain.vo.InpPhamDispenseDetailVO;
import com.th.supcom.pds.impl.common.utils.ExceptionThrowHelper;
import com.th.supcom.pds.impl.manager.OrderExecManager;
import com.th.supcom.pds.internal.api.phamapply.OrderBasicService;

public class OrderBasicServiceImpl implements OrderBasicService
{
    /** 日志记录器. */
    public static final Logger s_logger = LoggerFactory.getLogger (OrderBasicServiceImpl.class);
    private OrderExecManager m_orderExecManager;

    public void setOrderExecManager (OrderExecManager orderExecManager)
    {
        m_orderExecManager = orderExecManager;
    }

    @Override
    public List <InpPhamApplyDetailVO> findOrderExecListByExample (InpPhamApplyDetailVO inpPhamApplyDetailVO)
    {
        s_logger.info ("调用findOrderExecListByExample参数 ：inpPhamApplyDetailVO:{}", new Object[]
        { inpPhamApplyDetailVO });
        if (null == inpPhamApplyDetailVO)
        {
            s_logger.error ("查询医嘱拆分计划时，条件对象不能为空");
            throw new IllegalArgumentException ("查询医嘱拆分计划时，条件对象不能为空");
        }
        try
        {
            return m_orderExecManager.findOrderExecListByExample (inpPhamApplyDetailVO);
        }
        catch (Exception e)
        {
            s_logger.error ("查询医嘱拆分计划异常" + e.getLocalizedMessage (), e);
            throw new BusinessException ("查询医嘱拆分计划异常", e);
        }
    }

    @Override
    public List <InpPhamApplyDetailVO> findOrderContentByPaivisitAndOrderNo (List <InpPhamApplyDetailVO> detailVOList)
    {
        ExceptionThrowHelper.throwIllegalArgumentException (CollectionUtils.isEmpty (detailVOList), "通过住院流水号、医嘱序号、医嘱子序号查询医嘱内容，查询条件不能为空");
        try
        {
            return m_orderExecManager.findOrderContentByPaivisitAndOrderNo (detailVOList);
        }
        catch (Exception e)
        {
            s_logger.error ("通过住院流水号、医嘱序号、医嘱子序号查询医嘱内容异常" + e.getLocalizedMessage (), e);
            throw new BusinessException ("通过住院流水号、医嘱序号、医嘱子序号查询医嘱内容异常", e);
        }
    }

    @Override
    public List <InpPhamDispenseDetailVO> findDispensePhamOrderContent (List <InpPhamDispenseDetailVO> list)
    {
        ExceptionThrowHelper.throwIllegalArgumentException (CollectionUtils.isEmpty (list), "核对发药查询医嘱内容，查询条件不能为空");
        try
        {
            return m_orderExecManager.findDispensePhamOrderContent (list);
        }
        catch (Exception e)
        {
            s_logger.error ("核对发药查询医嘱内容异常" + e.getLocalizedMessage (), e);
            throw new BusinessException ("核对发药查询医嘱内容异常", e);
        }
    }

    /** 公司版权信息. */
    public static final String copyright = "Copyright 2014, XuNuo Corporation";

    /** 提交路径. */
    public static final String SCC_BRANCH = "$URL$";

    /** 提交日期. */
    public static final String SCC_LAST_MODIFICATION_DATE = "$Date$";

    /** 最终修改人员. */
    public static final String SCC_LAST_MODIFIER_NAME = "$Author$";

    /** 最终版本号. */
    public static final String SCC_REVISION = "$Revision$";

}
